<template>
  <div class="app-container">
    <!-- 全款项目流水单信息 -->
    <h5 class="titleInfo">全款项目流水单信息</h5>
    <el-form ref="list" :inline="true" :model="list" label-width="130px">
      <el-row>
        <el-col :span="12">
          <el-form-item label="流水单号">
            <span class="spanToInput">{{list.orderSn | filterNull}}</span>
          </el-form-item>
        </el-col>
        <el-col :span="12">
          <el-form-item label="预约单号">
            <span class="spanToInput">{{list.preOrderSn | filterNull}}</span>
          </el-form-item>
        </el-col>
        <el-col :span="12">
          <el-form-item label="订单号">
            <span class="spanToInput">{{list.projectOrderSn | filterNull}}</span>
          </el-form-item>
        </el-col>
        <el-col :span="12">
          <el-form-item label="流水单类型">
            <span class="spanToInput">{{list.type | filterNull}}</span>
          </el-form-item>
        </el-col>
        <el-col :span="12">
          <el-form-item label="预约医院">
            <span class="spanToInput">{{list.hospitalName | filterNull}}</span>
          </el-form-item>
        </el-col>
        <el-col :span="12">
          <el-form-item label="单数">
            <span class="spanToInput">{{list.num | filterNull}}</span>
          </el-form-item>
        </el-col>
        <el-col :span="12">
          <el-form-item label="创建日期">
            <span class="spanToInput">{{list.createdAt | filterNull}}</span>
          </el-form-item>
        </el-col>
        <el-col :span="12">
          <el-form-item label="刷卡日期">
            <span class="spanToInput">{{list.orderTime | filterNull}}</span>
          </el-form-item>
        </el-col>
      </el-row>
    </el-form>
    <!-- 人员信息 -->
    <div class="divBar"></div>
    <h5 class="titleInfo">人员信息</h5>
    <el-form ref="list" :inline="true" :model="list" label-width="130px">
      <el-row>
        <el-col :span="12">
          <el-form-item label="客户姓名">
            <span class="spanToInput">{{list.userName | filterNull}}</span>
          </el-form-item>
        </el-col>
        <el-col :span="12">
          <el-form-item label="客户手机号">
            <span class="spanToInput">{{list.userPhone | filterNull}}</span>
          </el-form-item>
        </el-col>
        <el-col :span="12">
          <el-form-item label="推荐人姓名">
            <span class="spanToInput">{{list.serviceName | filterNull}}</span>
          </el-form-item>
        </el-col>
        <el-col :span="12">
          <el-form-item label="推荐人手机号">
            <span class="spanToInput">{{list.servicePhone | filterNull}}</span>
          </el-form-item>
        </el-col>
        <el-col :span="12">
          <el-form-item label="团队姓名">
            <span class="spanToInput">{{list.teamUserName | filterNull}}</span>
          </el-form-item>
        </el-col>
        <el-col :span="12">
          <el-form-item label="团队手机号">
            <span class="spanToInput">{{list.teamUserPhone | filterNull}}</span>
          </el-form-item>
        </el-col>
        <el-col :span="12">
          <el-form-item label="管家姓名">
            <span class="spanToInput">{{list.butlerRealname | filterNull}}</span>
          </el-form-item>
        </el-col>
        <el-col :span="12">
          <el-form-item label="管家手机号">
            <span class="spanToInput">{{list.butlerUsername | filterNull}}</span>
          </el-form-item>
        </el-col>
      </el-row>
    </el-form>
    <!-- 支付信息 -->
    <div class="divBar"></div>
    <h5 class="titleInfo">支付信息</h5>
    <el-form ref="list" :inline="true" :model="list" label-width="130px">
      <el-row>
        <!-- orderSource == 1 || orderSource == 2，属于卡券项目 -->
        <div v-if="list.orderSource == 1 || list.orderSource == 2">
          <el-col :span="12">
            <el-form-item label="消费总金额">
              <span class="spanToInput">{{list.totalPrice | filterNull}}</span>
            </el-form-item>
          </el-col>
          <el-col :span="12">
            <el-form-item label="实付扣除杂费">
              <span class="spanToInput">{{list.allPrice | filterNull}}</span>
            </el-form-item>
          </el-col>
          <el-col :span="12">
            <el-form-item label="平台已支付现金">
              <span class="spanToInput">{{list.platformMoney | filterNull}}</span>
            </el-form-item>
          </el-col>
          <el-col :span="12">
            <el-form-item label="金币">
              <span class="spanToInput">{{list.goldCoin | filterNull}}</span>
            </el-form-item>
          </el-col>
        </div>
        <div v-else>
          <el-col :span="12">
            <el-form-item label="流水单金额">
              <span class="spanToInput">{{list.referee | filterNull}}</span>
            </el-form-item>
          </el-col>
          <el-col :span="12">
            <el-form-item label="消费总金额">
              <span class="spanToInput">{{list.totalPrice | filterNull}}</span>
            </el-form-item>
          </el-col>
          <el-col :span="12">
            <el-form-item label="现金补贴">
              <span class="spanToInput">{{list.cashAllowance | filterNull}}</span>
            </el-form-item>
          </el-col>
          <el-col :span="12">
            <el-form-item label="积分补贴">
              <span class="spanToInput">{{list.integralAllowance | filterNull}}</span>
            </el-form-item>
          </el-col>
        </div>
        <el-col :span="12" style="margin-top:20px;">
          <el-form-item label="支付凭证">
            <uploadImg
              ref="uploadImg"
              :disabled="$route.name == 'runWaterManFullInfo'"
              :file-num="fileNum"
              :file-list="fileList"
            />
          </el-form-item>
        </el-col>
        <el-col :span="12">
          <el-form-item label="备注">
            <el-input
              type="textarea"
              :rows="4"
              style="width:300px"
              placeholder="请输入内容"
              v-model="list.userRemark"
            ></el-input>
          </el-form-item>
        </el-col>
        <el-form-item>
          <el-button
            style="margin-top:30px;margin-left:130px"
            type="primary"
            @click="submitFn()"
          >立即提交</el-button>
        </el-form-item>
      </el-row>
    </el-form>
  </div>
</template>
<script>
import uploadImg from "@/components/UploadImg/index";
import { policy } from "@/api/policy";
import {
  getBeautyProjectOrderById,
  updateBeautyProjectOrder,
  updateBeautyProjectOrderljk
} from "@/api/runWaterManage";
export default {
  name: "runWaterManFullEdit",
  components: { uploadImg },
  data() {
    return {
      userId: "",
      list: {},
      fileNum: 3,
      fileList: []
    };
  },
  filters: {
    filterNull(e) {
      if (!e) {
        return "暂无";
      } else {
        return e;
      }
    },
    imgFilter(e) {
      return localStorage.getItem("imgUrlPrefix") + e;
    },
    cardNull(e) {
      return window.helper.cardType(e);
    },
    userFocus(e) {
      return window.helper.userFocus(e);
    }
  },
  inject: ["reload"],
  mounted() {
    this.userId = String(this.$route.query.userId);
    this.getList();
  },
  methods: {
    getList() {
      let datas = { id: this.userId };
      getBeautyProjectOrderById(datas)
        .then()
        .then(res => {
          console.log("res", res);
          if (!res.data.code) {
            this.list = res.data.data;
            this.list.img.forEach(i => {
              this.fileList.push({
                url: localStorage.getItem("imgUrlPrefix") + i
              });
            });
          } else {
            this.$message.error(res.data.msg);
          }
        })
        .catch(error => {
          this.$message.error(error);
        });
    },
    // 提交
    submitFn() {
      // 判断图片是否上传成功
      const uploadList = this.$refs.uploadImg.submitUpload();
      if (uploadList != "uploadError") {
        let datas = {
          id: this.userId,
          userRemark: this.list.userRemark,
          img: uploadList,
        //   allPrice:this.list.allPrice
        };
        updateBeautyProjectOrderljk(datas)
          .then(res => {
            if (!res.data.code) {
              this.$message({
                showClose: true,
                message: "修改成功",
                type: "success"
              });
              this.$router.push("/runWaterManageIndex");
              this.reload();
            } else {
              this.$message.error(res.data.msg);
            }
          })
          .catch(error => {
            this.$message.error(error);
          });
      } else {
        this.$message.error("图片上传失败");
      }
    }
  }
};
</script>

<style scoped>
.app-container {
  padding: 0px !important;
}
.form {
  margin-left: 268px;
}
</style>